//
//  VideoTableViewCell.m
//  VideoTest
//
//  Created by lanou3g on 15/5/29.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "VideoTableViewCell.h"

@implementation VideoTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(VideoModel *)model{
    if (_model !=model) {
        _model = model;
    }
    
    self.titleLabel.text = model.titleText;
    
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    CGFloat height = [[self class] getTitleHeigh:_titleLabel];
    CGRect frame = _titleLabel.frame;
    frame.size.height = height;
    _titleLabel.frame = frame;
    _titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
    _titleLabel.numberOfLines = 0;
    
    
}

+(CGFloat)getTitleHeigh:(UILabel*)label {
    CGSize size = CGSizeMake(CGRectGetWidth(label.frame), 1000);
    NSDictionary *dict = @{NSFontAttributeName:[UIFont systemFontOfSize:15]};
                           CGRect rect = [label.text boundingRectWithSize:size  options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil];
        
    return rect.size.height;
}

@end
